package com.rd.student.ruanjian.class4.lichunquan.Text02;

import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int size = sc.nextInt();
        int [][] arr = new int[size][size];
        for (int i = 0,j = 0, sum = 1; sum <= size*size;sum++) {
            for (; j < arr.length-1 && i < arr.length-1 && arr[i][j+1] ==0; j++) {
                arr[i][j] = sum;
                sum++;
            }
            arr[i][j] = sum;
            while( i < arr.length-1 && j <= arr.length-1 && arr[i+1][j] == 0) {
                i++;
                sum ++ ;
                arr[i][j] = sum;
            }
            while(i <= arr.length-1 && j>0 &&arr[i][j-1] == 0){
                sum++;
                j--;
                arr[i][j] = sum;

            }
            while(j<arr.length && i>1 && arr[i-1][j] == 0){
                sum++;
                i--;
                arr[i][j] =sum;
            }
            j++;
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }
    }
}
